<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <base href="http://localhost:8080/bookstore/">
    <link rel="stylesheet" href="static/style/bootstrap.min.css">
    <link rel="stylesheet" href="static/style/style.css">
    <script src="static/script/axios-0.18.0.js"></script>
    <script src="static/script/vue.js"></script>
    <link rel="stylesheet" href="element-ui-2.13.0/lib/theme-chalk/index.css">
    <script src="element-ui-2.13.0/lib/index.js"></script>
</head>
<body>
<div class="content center-pill" id="app">
    <div style="position:absolute;width: 400px;height: 400px;line-height: 400px">
        <div style="margin-top: 100px;text-align: center">
            <h3>图书商城</h3>
            <el-form :model="jsonUser" status-icon ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <div style="margin-left: 50px;width: 250px;">
                    <el-form-item label="账号" prop="pass">
                        <el-input type="text" v-model="jsonUser.username" autocomplete="off"></el-input>
                    </el-form-item>
                </div>
                <div style="margin-left: 50px;width: 250px;">
                    <el-form-item label="密码" prop="checkPass">
                        <el-input type="password" v-model="jsonUser.password" autocomplete="off"></el-input>
                    </el-form-item>
                </div>
                <el-form-item>
                    <el-button type="primary" @click="submitForm(jsonUser)">登录</el-button>
                </el-form-item>
                <div>
                    没有账号，前往登录： <a href="pages/user/register.html">注册</a>
                </div>
            </el-form>
        </div>
    </div>
</div>
<script>
    new Vue({
        el:"#app",
        data(){
            return{
                jsonUser:{
                    username: "",
                    password: ""
                },
                url:"pages/user/register.html"
            }
        },methods: {
            submitForm(formName) {
                axios.post("UserServlet?action=login", formName).then(
                    function (response) {
                        console.log(response.status)
                        if(response.status===201){
                            location.href="index.html"
                        }
                    },
                    function (err) {

                    }
                );
            }
        }
    })
</script>
</body>
</html>
